package xyz.worldzhile.chatroom.utils;

import com.alibaba.fastjson.JSON;
import xyz.worldzhile.chatroom.vo.MessageResult;

public class MessageUtil {

    public static MessageResult messageResult(boolean isBoard,String formName,Object message){
        MessageResult messageResult = new MessageResult();
        messageResult.setBroad(isBoard);
        messageResult.setMessage(message);

        if (formName!=null){
            messageResult.setFromName(formName);
        }

        return messageResult;
    }

    public static String messageResultString(boolean isBoard,String formName,Object message){
        MessageResult messageResult = new MessageResult();
        messageResult.setBroad(isBoard);
        messageResult.setMessage(message);

        if (formName!=null){
            messageResult.setFromName(formName);
        }

        return JSON.toJSONString(messageResult);
    }

}
